package com.tjetc.字符流;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class T03FileCopy {
    public static void main(String[] args) throws IOException {
        //节点流
        FileReader fileReader = new FileReader("myfile.txt");
        FileWriter fileWriter = new FileWriter("myfile2.txt");
        //水杯
        char[] chars= new char[1024];
        //每次接的水滴数
        int num;
        //循环,从输入管循环接水到水杯里,把水杯的水倒入输出管直到接完为止
        while((num=fileReader.read(chars))!=-1){
            fileWriter.write(chars,0,num);
        }
        //关管
        fileWriter.close();
        fileReader.close();
    }
}
